<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{$is_language?'充值':'Bonus RuiRu'}</title>
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" href="__MODULE_LIBS__/css/weui.min.css">
    <link rel="stylesheet" href="__MODULE_LIBS__/css/jquery-weui.css">
    <link rel="stylesheet" href="__MODULE_LIBS__/css/demos.css">
    <script src="__MODULE_LIBS__/js/jquery-2.1.4.js"></script>
    <script src="__MODULE_LIBS__/js/fastclick.js"></script>
    <script src="__MODULE_LIBS__/js/jquery-weui.js"></script>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }

        html {
            width: 100%;
            height: 100%;
            font-size: 20px;
            font-family: "Microsoft YaHei", "宋体", "Segoe UI", "Lucida Grande", Helvetica, Arial, sans-serif, FreeSans, Arimo;
            background: #F3F3F3;
        }

        body {
            margin: 0 auto;
            max-width: 750px;
            height: 100%;
            background: #F7F7F7;
        }

        /*顶部导航栏处的样式*/
        .navbar {
            position: relative;
            width: 100%;
            height: 2rem;
            font-size: 16px;
            color: #fff;
            line-height: 2rem;
            background: #373553;
        }

        .navbar-item {
            position: absolute;
            left: 0;
            top: 0;
            display: block;
            width: 3.2rem;
            height: 2rem;
            font-size: 14px;
            color: #fff;
            text-align: center;
        }

        .navbar-item > img {
            width: 0.8rem;
            height: 0.7rem;
            vertical-align: middle;
        }

        .navbar-center {
            text-align: center;
        }

        /*主体部分的样式*/
        .content {
            width: 100%;
        }

        .concenter {
            position: relative;
            padding: 0.5rem;
            margin-top: 1rem;
            background: #fff;
            overflow: hidden;
        }

        .title {
            font-size: 0.7rem;
        }

        #rmb {
            margin-top: 0.5rem;
            padding-left: 1.2rem;
            width: 100%;
            height: 1.8rem;
            font-size: 1.4rem;
            color: #555;
            border: 0;
            outline: none;
            border-bottom: 1px #ccc solid;
        }

        .fh {
            position: absolute;
            top: 1.9rem;
            left: 0.5rem;
            font-size: 1.5rem;
        }

        .conversion {
            margin-top: 0.2rem;
            font-size: 0.7rem;
            color: #f44444;
        }

        .remark {
            margin-top: 0.2rem;
            font-size: 0.7rem;
            color: #777;
            line-height: 1.4;
        }

    </style>
</head>
<body>
<header class="navbar">
    <a href="{:url('index/index')}" class="navbar-item">
        <img src="__MODULE_LIBS__/img/back.png"/>&nbsp;{$is_language?'返回':'Return'}
    </a>
    <div class="navbar-center">{$is_language?'充值':'Bonus RuiRu'}</div>
    <div class="navbar-item1">
        <select name="" id="yy">
            <option value="1" {$is_language?'selected':''}>中文</option>
            <option value="0" {$is_language?'':'selected'}>English</option>
        </select>
    </div>
</header>
<div class="content">
    <form action="" method="post">
        <div class="concenter">
            <div class="money">
                <span class="title">{$is_language?'充值美金':'Into the dollar'}</span>
                <span class="fh">$</span>
                <input type="number" name="mix_money" id="rmb" placeholder="0.00">
                {if $balance_data['is_balance']==1}
                <p class="conversion">{$is_language?'您的結算商等級為':'Your biller class is'}{$balance_data['balance_level']},{$is_language?'享受':'enjoy'}{$balance_data['balance_rate']*10}{$is_language?'折的優惠':'fold discounts'}，{$is_language?'實際充值的人民幣為':'The actual exchanged RMB is'}:￥<span class="conver_1">0.00</span></span></p>
                {else}
                <p class="conversion">{$is_language?'充值的人民幣為':'The amount of RMB exchanged'}￥<span
                        class="conver">0.00</span></p>
                {/if}
                <p class="remark">{$is_language?'備註：美金兌換人民幣比例':'Remarks: The platform settlement currency is
                    US dollars and US dollars are exchanged for RMB'}1:{$configs_data.exchange}</p>
            </div>
        </div>
        <div class="weui-btn-area">
            <input class="weui-btn weui-btn_warn" id="ackbtn" type="button"
                   value="{$is_language?'確&nbsp;定':'Determine'}">
        </div>
    </form>
</div>
<input type="hidden" name="yuyan" value="<?php echo @$is_language?>" id="yuyan">

<script type="text/javascript">

    $(document).on("change",'select#yy',function(){
        var yy = $(this).val();
        console.log(yy)
        var url = "{:url('index/language')}";
        $.post(url,{language:yy},function (res) {
            window.location.reload();
        })
    });
    $(function () {
//        FastClick.attach(document.body);
        $('#rmb').bind('input propertychange', function () {
            //进行相关操作
            var now = $(this).val();
            if (now == "") {
                $(".conver").html("0.00");
                $(".conver_1").html("0.00");
            } else {
                now = parseFloat(now);
                var last = now * {$configs_data.exchange};
                var last_1 = now * {$configs_data.exchange} * {$balance_data['balance_rate']};
                last = last.toFixed(2)+"";
                last = last.replace(/(\d{1,3})(?=(\d{3})+(?:$|\.))/g,'$1,');
                last_1 = last_1.toFixed(2)+"";
                last_1 = last_1.replace(/(\d{1,3})(?=(\d{3})+(?:$|\.))/g,'$1,');
                $(".conver").html(last);
                $(".conver_1").html(last_1);
            }
        });

        $("#ackbtn").click(function () {
            var yuyan = $('#yuyan').val();
            if(yuyan==1){
                $.confirm({
                    title: '提示',
                    text: '確定充值嗎？',
                    onOK: function () {
                        //点击确认
                        $.showLoading("充值處理中");
                        $.ajax({
                            type: "POST",
                            url: "{:url('mix/index')}",
                            dataType: "json",
                            data: {
                                mix_money: $("#rmb").val()
                            },
                            success: function (data) {
                                $.hideLoading();
                                $.alert(data.msg + "<br/>" + data.msg1, function () {
                                    window.location.reload();
                                    $("#rmb").val("");
                                    $(".conver").html("0.00");
                                });

                            }
                        })
                    }
                });
            }else{
                $.confirm({
                    title: 'Confirm',
                    text: 'Do you agree to cash in?',
                    onOK: function () {
                        //点击确认
                        $.showLoading("Charging treatment");
                        $.ajax({
                            type: "POST",
                            url: "{:url('mix/index')}",
                            dataType: "json",
                            data: {
                                mix_money: $("#rmb").val()
                            },
                            success: function (data) {
                                $.hideLoading();
                                $.alert(data.msg + "<br/>" + data.msg1, function () {
                                    window.location.reload();
                                    $("#rmb").val("");
                                    $(".conver").html("0.00");
                                });

                            }
                        })
                    }
                });
            }
        })

    })
</script>
</body>
</html>
